/* -------------------------------------------------------- antd -- */
import { useEffect } from 'react'
import { Modal } from 'antd'
/* -------------------------------------------------------- 确认弹窗 -- */
const Index = () => {
	const [ modal, contextHolder ] = Modal.useModal()
	
	useEffect(()=>{
		const comfirm = ({ title='提示', msg='确认删除？',  cancelText='取消', okText='确认', onOk, onCancel, type='confirm', closable=false, width }) =>{
			window.modal =  modal[type]({
				title,
				content:msg,
				cancelText,
				okText,
				onOk,
				centered: false,
				closable,
				className: 'confirm',
				width,
				onCancel: close => {
					if(window.$fn.hasObject(close)) return
					onCancel?.()
					close?.()
				}
			})
		}
		window.$fn.confirm = comfirm
	}, [ modal ])
	
	return <>{contextHolder}</>
}
export default Index